package book;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2022-08-23
 * Time: 21:24
 * name ：用以描述书
 */
public class Book {

    //private 体现封装性
    private String name; // 书名
    private String author; // 作者
    private String type; // 类型
    private double price; // 价格
    private boolean borrow; // 是否借出 -- 默认是flase 未被借出 -- 构造是可以不写入

    public Book(String name, String author, String type, double price) {
        this.name = name;
        this.author = author;
        this.type = type;
        this.price = price;
    }

    //private修饰的 需要获取和设置


    public void setName(String name) {
        this.name = name;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public void setType(String type) {
        this.type = type;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public void setBorrow(boolean borrow) {
        this.borrow = borrow;
    }

    public String getName() {
        return name;
    }

    public String getAuthor() {
        return author;
    }

    public String getType() {
        return type;
    }

    public double getPrice() {
        return price;
    }

    public boolean isBorrow() {
        return borrow;
    }

    @Override
    public String toString() {
        return "Book{" +
                "name='" + name + '\'' +
                ", author='" + author + '\'' +
                ", type='" + type + '\'' +
                ", price=" + price +
                ((isBorrow() == true)?", 已借出":", 未借出")+
                '}';
    }
}
